
#访问https://mermaid.live/网页进行图形化展示
def visualize_with_mermaid_code(graph):
    try:
        # 1. 获取Graph对象
        graph_obj = graph.get_graph()
        # 2. 关键修正：使用draw_mermaid()获取Mermaid语法文本（兼容旧版本）
        # draw_mermaid()返回的是字符串格式的Mermaid语法
        mermaid_text = graph_obj.draw_mermaid()
        return mermaid_text
    except Exception as e:
        print(f"渲染失败: {str(e)}")
        return "error"